[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/traverso/dialogs/project NewProjec...
From: |
Nicola Doebelin |
Subject: |
[Traverso-commit] traverso/src/traverso/dialogs/project NewProjec... |
Date: |
Wed, 21 May 2008 19:11:26 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Nicola Doebelin <n_doebelin> 08/05/21 19:11:26
Modified files:
src/traverso/dialogs/project: NewProjectDialog.cpp
NewProjectDialog.h
Log message:
* first dirty implementation of moving / copying audio files to project
directory
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/project/NewProjectDialog.cpp?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/dialogs/project/NewProjectDialog.h?cvsroot=traverso&r1=1.2&r2=1.3
Patches:
Index: NewProjectDialog.cpp
===================================================================
RCS file:
/sources/traverso/traverso/src/traverso/dialogs/project/NewProjectDialog.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- NewProjectDialog.cpp 21 May 2008 17:30:44 -0000 1.6
+++ NewProjectDialog.cpp 21 May 2008 19:11:26 -0000 1.7
@@ -34,6 +34,8 @@
#include <QTreeWidgetItem>
#include <QList>
#include <QFileInfo>
+#include <QFile>
+#include <QRadioButton>
#include <Config.h>
#include <Information.h>
@@ -146,6 +148,18 @@
if (loadFiles)
{
+ int mode = 0;
+ if (radioButtonCopy->isChecked())
+ {
+ mode = 1;
+ }
+
+ if (radioButtonMove->isChecked())
+ {
+ mode = 2;
+ }
+
+ move_files(mode);
load_files();
}
@@ -204,10 +218,59 @@
}
}
+void NewProjectDialog::move_files(int mode)
+{
+ // load from original location
+ if (mode == 0)
+ {
+ return;
+ }
+
+ QList<QFileInfo> list;
+ for(int n = 0; n < treeWidgetFiles->topLevelItemCount(); ++n) {
+ QTreeWidgetItem* item = treeWidgetFiles->topLevelItem(n);
+ list.append(QFileInfo(item->data(0,
Qt::ToolTipRole).toString()));
+ }
+
+ QString destination = pm().get_project()->get_root_dir() +
"/audiosources/";
+
+ // copy to project dir
+ for (int n = 0; n < list.size(); ++n)
+ {
+ QString fn = destination + list.at(n).fileName();
+
+ // TODO: check for free disk space
+ // TODO: progress dialog for copying files
+ // TODO: find the proper way for moving files. copy/delete
should not be necessare if the source and destination are on the same partition.
+
+ QFile f(list.at(n).absoluteFilePath());
+ if (f.copy(fn))
+ {
+ // copy was successful, thus update the file path
+ QTreeWidgetItem* item =
treeWidgetFiles->topLevelItem(n);
+ item->setData(0, Qt::ToolTipRole, fn);
+
+ // mode was "move", thus delete the source file
+ if (mode == 2)
+ {
+ if (!f.remove())
+ {
+ printf("could not delete file\n");
+ }
+ }
+ }
+ }
+}
+
void NewProjectDialog::load_files()
{
Sheet* sheet = pm().get_project()->get_current_sheet();
+ if (!sheet)
+ {
+ return;
+ }
+
int i = 0;
CommandGroup* group = new CommandGroup(sheet, tr("Import %n
audiofile(s)", "",
Index: NewProjectDialog.h
===================================================================
RCS file:
/sources/traverso/traverso/src/traverso/dialogs/project/NewProjectDialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- NewProjectDialog.h 20 May 2008 20:51:04 -0000 1.2
+++ NewProjectDialog.h 21 May 2008 19:11:26 -0000 1.3
@@ -33,13 +33,16 @@
NewProjectDialog(QWidget* parent = 0);
~NewProjectDialog();
+private:
+ void load_files();
+ void move_files(int);
+
private slots:
void accept();
void use_template_checkbox_state_changed(int state);
void update_template_combobox();
void add_files();
void remove_files();
- void load_files();
};
#endif