diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-10 18:35:14 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-07-10 18:35:14 +0000 |
commit | b700071a54e9ce9e9097a704fb1d71dc2a795bfb (patch) | |
tree | 07bcd0c87fa2a11400dda3447236a916ebbf2922 /fileview.cpp | |
parent | 4f1e2ee030f01facefab808f687d301c37707f74 (diff) | |
download | SheMov-b700071a54e9ce9e9097a704fb1d71dc2a795bfb.tar.gz SheMov-b700071a54e9ce9e9097a704fb1d71dc2a795bfb.tar.bz2 SheMov-b700071a54e9ce9e9097a704fb1d71dc2a795bfb.zip |
-fixed display of windowTitle
-focus FileView after startup and changing dir via directorybar
-implemented createFolder
-display action in statusBar()
git-svn-id: file:///var/svn/repos2/shemov/trunk@383 f440f766-f032-0410-8965-dc7d17de2ca0
Diffstat (limited to 'fileview.cpp')
-rw-r--r-- | fileview.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/fileview.cpp b/fileview.cpp index 31c9aca..5995d60 100644 --- a/fileview.cpp +++ b/fileview.cpp @@ -22,6 +22,8 @@ FileView::FileView(QWidget *parent) : QTreeView(parent) { setRootIsDecorated(false); mMarkDialog = new MessageDialog(tr("Enter pattern to mark"), this); connect(mMarkDialog, SIGNAL(accepted()), this, SLOT(doMark())); + mCreateFolderDialog = new MessageDialog(tr("Enter folder name"), this); + connect(mCreateFolderDialog, SIGNAL(accepted()), this, SLOT(doCreateFolder())); } void FileView::markFiles(){ @@ -32,6 +34,10 @@ void FileView::unmarkFiles(){ selectionModel()->clearSelection(); } +void FileView::createFolder(){ + mCreateFolderDialog->show(); +} + void FileView::doMark(){ int rowCount = model()->rowCount(rootIndex()); QString sRegex = mMarkDialog->text(); @@ -39,6 +45,7 @@ void FileView::doMark(){ QRegExp re(sRegex); QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(model()); QDirModel *model = static_cast<QDirModel*>(proxy->sourceModel()); + bool match(false); for(int i = 0; i < rowCount; ++i){ QModelIndex cur = rootIndex().child(i, 0); QModelIndex sCur = proxy->mapToSource(cur); @@ -47,8 +54,35 @@ void FileView::doMark(){ } if(re.indexIn(cur.data().toString()) != -1){ selectionModel()->select(cur, QItemSelectionModel::Select | QItemSelectionModel::Rows); + match = true; } } + if(match){ + statusbarMessage(QString()); + }else{ + emit statusbarMessage(tr("No match found!")); + } + }else{ + emit statusbarMessage(tr("Nothing to mark!")); + } +} + +void FileView::doCreateFolder(){ + QString folderName = mCreateFolderDialog->text(); + if(folderName.isEmpty()){ + emit statusbarMessage(tr("No foldername given!")); + return; + } + QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(model()); + QDirModel *model = static_cast<QDirModel*>(proxy->sourceModel()); + QModelIndex sRoot = proxy->mapToSource(rootIndex()); + QModelIndex newIdx = model->mkdir(sRoot, folderName); + if(newIdx == QModelIndex()){ + QString msg = QString(tr("Failed to create %1/%2")).arg(model->filePath(sRoot)).arg(folderName); + emit statusbarMessage(msg); + }else{ + QString msg = QString(tr("Created folder %1")).arg(model->filePath(newIdx)); + emit statusbarMessage(msg); } } @@ -57,7 +91,7 @@ void FileView::contextMenuEvent(QContextMenuEvent *e){ int ctr(0); foreach(QAction *a, actions()){ contextMenu.addAction(a); - if(false){ + if((ctr == 1)){ contextMenu.addSeparator(); } ++ctr; |